/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.view.memberView;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.KeyStroke;

import com.ruipengkj.bean.TUser;
import com.ruipengkj.commons.util.Util;
import com.ruipengkj.component.JLabelJTextAreaComponent;
import com.ruipengkj.component.JLabelJTextFieldComponent;
import com.ruipengkj.component.RPJButtonGray;
import com.ruipengkj.view.base.BaseDialog;

/**
 * 说明：
 * 会员详细Dialog
 * @Author：李智深
 * @Date：2012-03-20
 */
public class MenberDetailDialog extends BaseDialog{

	private static final long serialVersionUID = 1L;
	
	private JButton okButton;//确定
	private JLabelJTextFieldComponent menberNumberTF=null;//会员编号
	private JLabelJTextFieldComponent menberCardId;//会员卡号
	private JLabelJTextFieldComponent menberUserNameTF=null;//用户名
	private JLabelJTextFieldComponent menberRealName=null;//姓名
	private JLabelJTextFieldComponent menberMobileTF=null;//手机号
	private JLabelJTextFieldComponent menberEMailTF=null;//邮件地址
	private JLabelJTextFieldComponent menberPostCode=null;//邮编
	private JLabelJTextFieldComponent menberNationalID=null;//身份证号码
	private JLabelJTextFieldComponent menberBirthDate=null;//出身日期
	private JLabelJTextFieldComponent menberBuyCount=null;//消费次数
	private JLabelJTextFieldComponent menberStatusTF=null;//状态
	private JLabelJTextAreaComponent menberLocation=null;//详细地址
	private JLabelJTextFieldComponent menberCreateTime=null;//注册时间
	public MenberDetailDialog(JDialog jd, String title, boolean b) {
		super(jd, title, b);
		this.init();
		this.setSize(300, 550);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
	}
	private void init(){
		this.initViews();
		this.initListener();
	}
	
	private void initViews(){
		JPanel main_jp=new JPanel();
		BoxLayout boxLayout=new BoxLayout(main_jp,BoxLayout.Y_AXIS);
		main_jp.setLayout(boxLayout);
		main_jp.setBackground(Util.PANEL_COLOR);
		
		menberNumberTF=new JLabelJTextFieldComponent("会员编号：",30);
		menberCardId = new JLabelJTextFieldComponent("会员卡号：", 30);
		menberUserNameTF=new JLabelJTextFieldComponent("用 户 名：",30);
		menberRealName=new JLabelJTextFieldComponent("姓    名：",30);
		menberMobileTF=new JLabelJTextFieldComponent("手 机 号：",30);
		menberEMailTF=new JLabelJTextFieldComponent("邮件地址：",30);
		menberPostCode=new JLabelJTextFieldComponent("邮    编：",30);
		menberNationalID=new JLabelJTextFieldComponent("身份证号：",30);
		menberBirthDate=new JLabelJTextFieldComponent("出生日期：",30);
		menberBuyCount=new JLabelJTextFieldComponent("消费次数：",30);
		menberStatusTF=new JLabelJTextFieldComponent("状    态：",30);
		menberLocation=new JLabelJTextAreaComponent("详细地址：", 23, 2);
		menberCreateTime=new JLabelJTextFieldComponent("注册时间：",30);
		menberNumberTF.getText().setEditable(false);
		JPanel jp1=new JPanel();
		okButton=new RPJButtonGray("关闭");
		jp1.add(okButton);
		jp1.setOpaque(false);
		
		main_jp.add(menberNumberTF);
		main_jp.add(menberCardId);
		main_jp.add(menberUserNameTF);
		main_jp.add(menberRealName);
		main_jp.add(menberMobileTF);
		main_jp.add(menberEMailTF);
		main_jp.add(menberPostCode);
		main_jp.add(menberNationalID);
		main_jp.add(menberBirthDate);
		main_jp.add(menberBuyCount);
		main_jp.add(menberStatusTF);
		main_jp.add(menberLocation);
		main_jp.add(menberCreateTime);
		main_jp.add(jp1);
		
		this.add(main_jp);
	}
	private void initListener(){
		okButton.addActionListener(this);
		okButton.registerKeyboardAction(this, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==okButton){
			//确定
			this.dispose();
		}
	}
	
	public void showDialog(TUser user){
		if(user!=null){
			menberNumberTF.getText().setText(user.getUserID());
			menberCardId.getText().setText(user.getCardNum());
			menberUserNameTF.getText().setText(user.getUserName());
			menberRealName.getText().setText(user.getRealName());
			menberMobileTF.getText().setText(user.getMobile());
			menberEMailTF.getText().setText(user.getEMail());
			menberPostCode.getText().setText(user.getPostCode());
			menberNationalID.getText().setText(user.getNationalID());
			menberBirthDate.getText().setText(user.getBirthDate());
			menberBuyCount.getText().setText(user.getBuyCount()+"");
			menberLocation.getArea().setText(user.getLocation());
			if(user.getStatus()==1){
				menberStatusTF.getText().setText("正常");
			}else{
				menberStatusTF.getText().setText("锁定");
			}
			menberCreateTime.getText().setText(user.getCreateTime().toString());
		}
		this.setVisible(true);
	}
}
